const express = require("express");
const path = require("path");
let app = express();

app.get("/", (req, res) => {
  // 加载index.html页面
  res.sendFile(path.join(__dirname, "./views/index.html"));
})

app.get("/checkusername", (req, res) => {
  // 接收用户名
  let { username } = req.query;
  console.log(username);
  if (username == "程宇") {
    let obj = {
      info: "用户名正确",
      status: 1
    };
    res.json(obj);
  } else {
    let obj = {
      info: "用户名错误",
      status: 0
    };
    res.json(obj)
  }
})
app.listen(8080);
